# 479 困难：最大回文数乘积

def largestPalindrome(n: int) -> int:
    if n == 1:
        return 9

    small = 10 ** (n - 1)
    big = 10 ** n - 1
    for i in range(big, small - 1, -1):
        left, right = i, i
        while right:
            # 回文数构造方法
            left = left * 10 + right % 10
            right //= 10
        print(left)
        m = big
        while m ** 2 >= left:
            if left % m == 0:
                return left % 1337
            m -= 1


print(largestPalindrome(2))
